<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.ax.pojo.TabConfig"%>
<%@page import="com.ax.pojo.TabDown"%>
<%@include file="inc/CheckLogin.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta content="text/html; charset=GB2312" http-equiv="Content-Type">
<title>内容管理</title>
<link type="text/css" rel="stylesheet" href="images/style.Css">
<script type="text/javascript" src="<%=basePath %>js/jquery-1.5.2.min.js"></script>
<script type="text/javascript">
  function changeSel(sel){
     document.getElementById("cauthor").value=sel.value;
  }
  function changeSelSource(sel){
     document.getElementById("csource").value=sel.value;
  }
  
  function addDown(){
     var  SoftListDiv=document.getElementById("SoftListDiv").innerHTML;
     SoftListDiv="<div>"+SoftListDiv+"</div>";
     document.getElementById("adddowns").innerHTML=document.getElementById("adddowns").innerHTML+"<br>"+SoftListDiv;
  }
  
  function checkevn()
  {
   	  var val="";
      var en0=document.getElementsByName("en0");
      for(var i=0;i<en0.length;i++){
         if(en0[i].checked==true){
           val+=en0[i].value+",";
         }
      }
      
       document.getElementById("csoftEnvironment").value=val;
  }
  
  function save(){
    var oCid=document.getElementById("oCid");
    var oTitle=document.getElementById("oTitle");
    var cpush=document.getElementById("cpush");
    var cauthor=document.getElementById("cauthor");
    var csource=document.getElementById("csource");
    var cviews=document.getElementById("cviews");
    var cdownNum=document.getElementById("cdownNum");
    var ckeywords=document.getElementById("ckeywords");
    var csoftEnvironment=document.getElementById("csoftEnvironment");
    var csoftSize=document.getElementById("csoftSize");
    var oUnit=document.getElementById("oUnit");
    var csoftLanguage=document.getElementById("csoftLanguage");
    var csoftRank=document.getElementById("csoftRank");
    var csoftImpower=document.getElementById("csoftImpower");
    var csoftRank=document.getElementById("csoftRank");
    var csoftPlugin=document.getElementById("csoftPlugin");
    var ccontent=document.getElementById("ccontent");
    if(oCid.value=="-1"){
    	alert("不能选择大栏目");
    	return false;
    }else if(oTitle.value==""){
     	alert("标题不能为空");
    	return false;
    }else if(ccontent.value==""){
       alert("内容不能为空");
       return false;
    }
    
    
     var oServerID=document.getElementById("adddowns").getElementsByTagName("select");
     var oSoftDir=document.getElementById("adddowns").getElementsByTagName("input");
     var downpath=""
     for(var i=0;i<oServerID.length;i++){
         if(oSoftDir[i].value!=""){
            downpath+=oServerID[i].value+":"+oSoftDir[i].value+",";
         }
         
     }
    var push=""; 
    if(cpush.checked==true){
     push="1";
    }else{
    push=cpush.value;
    }
     
     var data={oCid:oCid.value,oTitle:oTitle.value,cpush:push,cauthor:cauthor.value,csource:csource.value,cviews:cviews.value,cdownNum:cdownNum.value,ckeywords:ckeywords.value,csoftEnvironment:csoftEnvironment.value,csoftSize:csoftSize.value+oUnit.value,csoftLanguage:csoftLanguage.value,csoftRank:csoftRank.value,csoftImpower:csoftImpower.value,csoftPlugin:csoftPlugin.value,ccontent:ccontent.value,downpath:downpath};
     	 $.post("contentsAction!add.do",data,function(data){
               var flag=eval(data);
               if(flag){
                   var i=window.confirm("是否继续添加内容");
                   if(i){
                      window.location.href="contentsAction!findTypes.do";
                   }else{
                     window.location.href="contentsAction!find.do";
                   }
               }else{
                  alert("添加内容失败");
               }
     });
   return false;
  }
</script>
</head>
<body>

<table width="100%" cellspacing="1" cellpadding="3" border="0" bgcolor="#E1E1E1" class="css_table">
	<tbody><tr class="css_menu">
		<td colspan="5"><table width="100%" cellspacing="0" cellpadding="4" border="0" class="css_main_table">
				<tbody><tr>
					<td class="css_main"><a href="contentsAction!find.do">内容管理</a></td>
				</tr>
			</tbody></table></td>
	</tr>
	<form action="Admin_Content.Asp?Act=UpDate&amp;ID=&amp;Page=1&amp;Key=15&amp;DFieldKey=Cid&amp;Orders=Desc&amp;DFieldOrders=ID" method="post" name="frm"></form>
		<tr>
			<td width="94" class="css_col12_content"><div align="right"> <font color="red">栏目：</font> </div></td>
			<td class="css_col22" colspan="4">
			<select id="oCid" type="text" name="oCid" class="css_select">
			<%=request.getAttribute("types") %>
			</select>
 </td>
		</tr>
		<%	Map<String, TabConfig> map=(Map<String, TabConfig>)request.getAttribute("map"); %>
		<tr>
			<td class="css_col11_content"><div align="right"> <font color="red">标题：</font> </div></td>
			<td class="css_col21" colspan="4"><input type="text" size="70" value=""  id="oTitle" class="css_input" name="ctitle;">
				<input type="checkbox" value="0" name="cpush"> 推荐
			</td>
		</tr>
		<tr>
			<td class="css_col12_content"><div align="right"> 属性： </div></td>
			<td class="css_col22" colspan="4"><table cellspacing="0" cellpadding="0" border="0">
					<tbody><tr>
             <td><input type="text" size="6" value="Admin" id="cauthor" class="css_input" name="cauthor">
							<select onchange="changeSel(this)" name="select">
							<%
							    String author[]=(map.get("Author").getCvalue()).split(",");
							    for(int i=0;i<author.length;i++){
							      
							 %>
								<option value="<%=author[i] %>"><%=author[i] %></option>
								<%
								}
								 %>
							</select>						</td>
						<td width="10">&nbsp;</td>
						<td>来源：</td>
						<td><input type="text" size="6" value="未知" id="csource" class="css_input" name="csource">
							<select onchange="changeSelSource(this)" name="select2">
					           <%
					                String source[]=(map.get("Source").getCvalue()).split(",");
					                    for(int i=0;i<source.length;i++){
					            %>
								<option value="<%=source[i] %>"><%=source[i] %></option>
								<%} %>
							</select>						</td>		
						<td width="10"></td>
						<td>浏览：</td>
						<td><input type="text" size="2" value="0" id="cviews" name="cviews" class="css_input">						</td>
						<td width="10"></td>
						<td>下载：</td>
						<td><input type="text" size="2" value="0" id="cdownNum" name="cdownNum" class="css_input">						</td>
						<td width="10"></td>
						<td>&nbsp;</td>
						<td>&nbsp;				</td>
						<td width="10">&nbsp;</td><td>&nbsp;</td>
						<td>&nbsp;</td>
					</tr>
				</tbody></table></td>
		</tr>
		

		<tr>
			<td class="css_col12_content"><div align="right"> 关键字/标签： </div></td>
			<td class="css_col22" colspan="4"><input type="text" size="32" value="" id="ckeywords" class="css_input" name="ckeywords">
		编辑描述 (多个关键字请用英文状态下的逗号分隔) </td>
		</tr>
		<!--Add New-->
		<tr id="sdiv1">
			<td class="css_col12_content"><div align="right"> 运行环境： </div></td>
			<td class="css_col22" colspan="4">
			<input type="text" size="32" value="" id="csoftEnvironment" class="css_input" name="csoftEnvironment"> 
			<%
			 String softEnvironment[]=map.get("SoftEnvironment").getCvalue().split(",");
			 for(int i=0;i<softEnvironment.length;i++){
			 %>
			<input type="checkbox"  onclick="checkevn()" value="<%=softEnvironment[i] %>" name="en0"><%=softEnvironment[i] %>&nbsp;
			<%
			}
			 %>
			</td>
		</tr>
		<tr id="sdiv2">
			<td class="css_col12_content"><div align="right"> 相关属性： </div></td>
			<td class="css_col22" colspan="4">
			软件大小 <input type="text" size="7" value="0" class="css_input" id="csoftSize" name="csoftSize">
			<select name="oUnit"><option value="kb">KB</option><option value="mb">MB</option></select> 
			语言 <select name="csoftLanguage">
								<%
								  String softLanguage[]=map.get("SoftLanguage").getCvalue().split(",");
								  for(int i=0;i<softLanguage.length;i++){
								 %>
								<option value="<%=softLanguage[i] %>"><%=softLanguage[i] %></option>
								<%
								}
								 %>
							</select>
			授权 <select name="csoftImpower">
								<%
								 String softImpower[]=map.get("SoftImpower").getCvalue().split(",");
								  for(int i=0;i<softImpower.length;i++){
								 %>
								<option value="<%=softImpower[i] %>"><%=softImpower[i] %></option>
								<%} %>
							</select>
			
			评价等级 <select name="csoftRank">
			<option value="1"> 1 级</option><option value="2"> 2 级</option><option selected="" value="3"> 3 级</option><option value="4"> 4 级</option><option value="5"> 5 级</option>
			</select>
			插件 <select name="csoftPlugin">
			<option selected="" value="0">无 插件</option><option value="1">有 插件</option>
			</select>

			</td>
		</tr>
		<tr style="display:none" id="uploadTr">
			<td class="css_col12_content"><div align="right" style="color:blue;"> 上传软件： </div></td>
			<td class="css_col22" colspan="4">
			</td>
		</tr>		
	

		<tr id="trdescription" style="display:none;">
			<td class="css_col11_content"><div align="right"> 描述： </div></td>
			<td class="css_col21" colspan="4"><textarea type="text" id="oDescription" class="css_textarea" rows="3" style="width:99.2%;" name="oDescription"></textarea>			</td>
		</tr>
		<tr id="sdiv3">
			<td class="css_col12_content"><div align="right"> 软件地址列表：
			<br><input type="button" onclick="addDown();" value="增加"> 
			</div></td>
			<td class="css_col22" id="adddowns" colspan="4">
			<div id="SoftListDiv">服务器
			 <select name="oServerID" id="oServerID">
			 <%
			 List<TabDown> list=(List<TabDown>)request.getAttribute("down");
			for(int i=0;i<list.size();i++){
			TabDown down=list.get(i);
			  %>
			 <option value="<%=down.getDvalue()%>"><%=down.getDvalue() %></option>
			 <%} %>
			</select>&nbsp;
			 路径 <input type="text" value="" size="40" id="oSoftDir" name="oSoftDir">
			 </div>
			</td>
		</tr>
		<tr id="trcontent">
			<td class="css_col11_content"><div align="right"> <font color="red">内容：</font><br>
					
					 </div></td>
			<td class="css_col21" colspan="4">
			 <textarea rows="10" style="width: 100%;" name="ccontent"></textarea>
			
			</td>
		</tr>
		<tr class="css_page_list">
			<td colspan="5"><input type="button" value="保存"  onclick="save()" name="Submit">			</td>
		</tr>
	
</tbody></table>




</body></html>